package main

import (
	"fmt"
	"gitee.com/lvshicong/inspection-helper/internal/logger"
	"gitee.com/lvshicong/inspection-helper/internal/services"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/common/expfmt"
	"os"
)

func main() {
	// 初始化全局日志记录器
	logger.InitLogger()
	log := logger.GetLogger()

	retgistry := prometheus.NewRegistry()
	collector := services.NewMyCollector()
	err := retgistry.Register(collector)
	if err != nil {
		log.Error(fmt.Sprintf("Error register: %v", err))
		os.Exit(1)
	}
	mf, err := retgistry.Gather()
	if err != nil {
		log.Error(fmt.Sprintf("Error gathering metrics: %v", err))
		os.Exit(1)
	}
	enc := expfmt.NewEncoder(os.Stdout, expfmt.FmtText)
	for i := range mf {
		enc.Encode(mf[i])
	}
}
